package com.ysxsoft.wdg.ui.activity.my.jf;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.base.BaseActivity;
import com.ysxsoft.wdg.bean.response.JiFenDescriptionResponse;
import com.ysxsoft.wdg.bean.response.JiFenExchangeResponse;
import com.ysxsoft.wdg.net.CallbackCode;
import com.ysxsoft.wdg.net.UrlHost;
import com.ysxsoft.wdg.util.JsonUtils;
import com.ysxsoft.wdg.util.ToastUtils;
import com.ysxsoft.wdg.util.WebViewUtils;
import com.ysxsoft.wdg.util.sp.SharePrefUtils;
import com.ysxsoft.wdg.util.statusbar.StatusBarUtil;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.Call;

public class JfDescActivity extends BaseActivity {

    public static void start(Context context){
        Intent intent = new Intent(context,JfDescActivity.class);
        context.startActivity(intent);
    }


    @BindView(R.id.topView)
    View topView;
    @BindView(R.id.title_content)
    TextView titleContent;
    @BindView(R.id.webView)
    WebView webView;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_jf_desc;
    }

    @Override
    protected void initData() {
        StatusBarUtil.setStatusBarTextColor(this,true);
        initStatusBar(topView,true);
        titleContent.setText("积分说明");

        WebViewUtils.init(webView);
        getDetail();
    }

    @Override
    protected void setListener() {

    }


    @OnClick(R.id.title_finish)
    public void onViewClicked() {
        finish();
    }

    /**
     * 积分说明
     */
    private void getDetail(){
        OkHttpUtils.post()
                .url(UrlHost.FEN_DESCRIPTION)
                .build().execute(new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                if (!call.isCanceled()) {
                }
            }

            @Override
            public void onResponse(String response, int id) {
                if (response != null) {
                    JiFenDescriptionResponse bean = JsonUtils.parseByGson(response, JiFenDescriptionResponse.class);
                    if (bean == null) {
                        return;
                    }
                    if (CallbackCode.SUCCESS.equals(bean.getCode())) {
                        WebViewUtils.setData(webView,bean.getData());
                    }else{
                        ToastUtils.showToast(bean.getMs());
                    }
                } else {
                }
            }
        });
    }
}
